<?php

namespace pmvc\log;

use DateTime;

/**
 * Appender that delegates to a closure.
 */
class ClosureAppender
	implements Appender {

	private $closure;

	/**
	 * Creates the appender with the given underlying
	 * closure
	 * 
	 * @param callback $closure
	 */
	public function __construct($closure) {
		$this->closure = $closure;
	}
	/**
	 * {@inheritDoc}
	 */
	public function append($level, DateTime $time, $name, $message) {
	    $fun = $this->closure;
	    $fun($level, $time, $name, $message);
	}

}

?>